import api from './auth.js'

// 图书相关API
export const bookAPI = {
  // 获取推荐图书列表
  getRecommendedBooks: (limit = 10) => {
    return api.get('/books/recommended', { params: { limit } })
  },

  // 获取新书上架列表
  getNewBooks: (limit = 10) => {
    return api.get('/books/new', { params: { limit } })
  },

  // 获取个性化推荐图书列表
  getPersonalizedBooks: (limit = 10) => {
    return api.get('/books/personalized', { params: { limit } })
  },

  // 获取图书详情
  getBookDetail: (bookId) => {
    return api.get(`/books/${bookId}`)
  },

  // 获取热门图书列表
  getPopularBooks: (limit = 10) => {
    return api.get('/books/popular', { params: { limit } })
  },

  // 搜索图书
  searchBooks: (params) => {
    return api.get('/books/search', { params })
  },

  // 按分类获取图书
  getBooksByCategory: (categoryId, params) => {
    return api.get(`/books/category/${categoryId}`, { params })
  },

  // 获取畅销榜单
  getBestsellerList: (params) => {
    return api.get('/books/bestsellers', { params })
  },

  // 获取图书分类列表
  getCategories: () => {
    return api.get('/books/categories')
  },

  // 获取图书评论列表
  getBookReviews: (bookId, params) => {
    return api.get(`/books/${bookId}/reviews`, { params })
  },

  // 创建图书评论
  createBookReview: (bookId, reviewData) => {
    return api.post(`/books/${bookId}/reviews`, reviewData)
  },

  // 点赞/取消点赞评论
  toggleReviewLike: (reviewId) => {
    return api.post(`/books/reviews/${reviewId}/like`)
  }
}

export default bookAPI
